package archer.application.core.entity.system;

import archer.application.core.constant.Constant;
import archer.framework.common.entity.BaseEntity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.OneToMany;
import javax.persistence.UniqueConstraint;
import java.util.List;

/**
 * 角色
 *
 * @author christ
 * @date 2016/6/7
 */
@Entity
@UniqueConstraint(columnNames = {"code"})
public class Role extends BaseEntity {

    public static final Find<Role> find = new Find<Role>(Role.class);

    //--------------------------
    //  fields
    //--------------------------
    @Column(columnDefinition = " varchar(64) COMMENT '角色名称'")
    private String name;

    @Column(columnDefinition = " varchar(64) BINARY COMMENT '角色编码'")
    private String code;

    @Column(columnDefinition = "char(1)  default 'N' COMMENT '是否系统数据'")
    protected String sysData = Constant.EntityDefault.N;

    @Column(columnDefinition = " varchar(256) COMMENT '角色简介'")
    private String remark;

    //--------------------------
    //  relations
    //--------------------------
    @OneToMany(mappedBy = "role")
    private List<UserRoleRel> userRoleRels;

    @OneToMany(mappedBy = "role")
    private List<RoleMenuRel> roleMenuRels;

    //--------------------------
    //  getter setter
    //--------------------------
    public String getName() {
        return name;
    }

    public Role setName(String name) {
        this.name = name;
        return this;
    }

    public String getCode() {
        return code;
    }

    public Role setCode(String code) {
        this.code = code;
        return this;
    }

    public String getRemark() {
        return remark;
    }

    public Role setRemark(String remark) {
        this.remark = remark;
        return this;
    }

    public List<UserRoleRel> getUserRoleRels() {
        return userRoleRels;
    }

    public Role setUserRoleRels(List<UserRoleRel> userRoleRels) {
        this.userRoleRels = userRoleRels;
        return this;
    }

    public List<RoleMenuRel> getRoleMenuRels() {
        return roleMenuRels;
    }

    public Role setRoleMenuRels(List<RoleMenuRel> roleMenuRels) {
        this.roleMenuRels = roleMenuRels;
        return this;
    }

    public String getSysData() {
        return sysData;
    }

    public Role setSysData(String sysData) {
        this.sysData = sysData;
        return this;
    }
}
